#!/usr/bin/python
#
# Copyright (c) 2009 Julius Volz
# See LICENSE for details.

from elixir import *
import sqlalchemy as sa

#metadata.bind.echo = True

class ResourceChange(Entity):
  seqnum = Field(Integer, primary_key=True)
  resource = Field(Text)
  changetype = Field(Integer)

  def __repr__(self):
    return '<ResourceChange %s, %s: %s)>' % (self.timestamp, self.seqnum, self.resource)

class Link(Entity):
  source = Field(Text)
  linktype = Field(Text)
  target = Field(Text)
  linkspec = Field(Text)
  monitored = OneToMany('silk.sync.source.model.MonitoredResource')

  using_table_options(sa.UniqueConstraint('source', 'linktype', 'target'))

class MonitoredResource(Entity):
  resource = Field(Text)
  link = ManyToOne('silk.sync.source.model.Link')
